package com.cljz.makepassenger.ui.holder;


import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.CheckBox;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.cljz.makepassenger.R;
import com.cljz.makepassenger.model.net.bean.NoticeListBean;

import java.util.ArrayList;

import butterknife.BindView;
import butterknife.ButterKnife;

/**
 * Created by apple on 2017/5/14.
 */

public class SystemMsgListHolder extends RecyclerView.ViewHolder {
    @BindView(R.id.tv_system_msg_time)
    TextView tvSystemMsgTime;
    @BindView(R.id.iv_system_msg_hint)
    ImageView ivSystemMsgHint;
    @BindView(R.id.tv_system_msg_title)
    TextView tvSystemMsgTitle;
    @BindView(R.id.ll_system_msg_contain)
    LinearLayout llSystemMsgContain;
    @BindView(R.id.tv_system_msg_des)
    TextView tvSystemMsgDes;
    @BindView(R.id.cb_selected)
    CheckBox cbSelected;
    @BindView(R.id.rl_system_msg_contain)
    RelativeLayout rlSystemMsgContain;
    private NoticeListBean.DataBeanX data;

    public SystemMsgListHolder(View itemView) {
        super(itemView);
        ButterKnife.bind(this, itemView);

    }

    public void setData(ArrayList<NoticeListBean.DataBeanX> noticeList, int position, boolean isDelete) {
        data = noticeList.get(position);
        tvSystemMsgTime.setText(data.getAdd_time());
        tvSystemMsgTitle.setText(data.getMsg());
        tvSystemMsgDes.setText(data.getExtra().getExtra());
        ivSystemMsgHint.setVisibility("0".equals(data.getIs_read()) ? View.VISIBLE : View.INVISIBLE);
        if (isDelete) {
            cbSelected.setVisibility(View.VISIBLE);
            if (data.isHasSelected()) {
                cbSelected.setChecked(true);
                rlSystemMsgContain.setBackgroundResource(R.drawable.shape_system_card_select_bg);
            } else {
                cbSelected.setChecked(false);
                rlSystemMsgContain.setBackgroundResource(R.drawable.shape_system_card_bg);
            }
        } else {
            cbSelected.setVisibility(View.GONE);
            rlSystemMsgContain.setBackgroundResource(R.drawable.shape_system_card_bg);
        }
        if (position == noticeList.size() - 1) {
            itemView.setPadding(0,0,0,20);
        }
    }
}
